package collection2;

import java.util.*;

/**
 * @Auther: 杨通通
 * @Date: 2024/10/27 23:36
 * @Description:
 */
public class set1 {

    public static void main(String[] args) {
        HashSet<String> set1 = new HashSet<>();
        set1.add("c");
        set1.add("b");
        set1.add("a");
        String[] array = set1.toArray(new String[set1.size()]);

        System.out.println(set1);
        System.out.println(array);
        set1.add("b");
        System.out.println(set1);

        set1.forEach(System.out::println);

        LinkedHashSet<String> set2 = new LinkedHashSet<>();
        set2.addAll(Arrays.asList("c","b","a"));
        set2.forEach(System.out::println);
//        System.out.println(set2);


//        treeSet 自动排序
        TreeSet<String> orderedSet = new TreeSet<>(Arrays.asList("c","d","a","v"));
        System.out.println(orderedSet);
    }
}